Statistics
| Branch: | Tag: | Revision:

chatsecureios / ChatSecure / Classes / View Controllers / OTRMessagesCollectionViewFlowLayout.swift @ f3813541

History | View | Annotate | Download (982 Bytes)

1
//
2
//  OTRMessagesCollectionViewFlowLayout.swift
3
//  ChatSecure
4
//
5
//  Created by David Chiles on 3/4/16.
6
//  Copyright © 2016 Chris Ballinger. All rights reserved.
7
//
8

    
9
import Foundation
10

    
11
import JSQMessagesViewController
12

    
13
@objc public protocol OTRMessagesCollectionViewFlowLayoutSizeProtocol {
14
    func hasBubbleSizeForCellAtIndexPath(_ indexPath: IndexPath) -> Bool
15
}
16

    
17
@objc open class OTRMessagesCollectionViewFlowLayout:JSQMessagesCollectionViewFlowLayout {
18
    
19
    @objc open weak var sizeDelegate:OTRMessagesCollectionViewFlowLayoutSizeProtocol?
20
    
21
    @objc override open func messageBubbleSizeForItem(at indexPath: IndexPath!) -> CGSize {
22
        guard let delegate = self.sizeDelegate, !delegate.hasBubbleSizeForCellAtIndexPath(indexPath) else {
23
            return super.messageBubbleSizeForItem(at: indexPath)
24
        }
25
        
26
        //Set width to one because of an Assert inside of JSQMessagesViewController
27
        return CGSize(width: 1, height: 0)
28
    }
29
    
30
}